import { Toast } from 'vant'

export const GetIsWechat = () => {
  const nav = window.navigator.userAgent.toLowerCase()
  return nav.includes('micromessenger')
}

export const InitWxLogin = () => {
  // 获取hash值

  if (GetIsWechat()) {
    const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5145116d628bec60&redirect_uri=${encodeURI(
      `https://ctx.happysooner.com/nanc-h5/auth?from=${window.location.href}`
    )}&response_type=code&scope=snsapi_userinfo&state=ops}`
    window.location.href = url
  } else {
    Toast('当前操作仅支持微信内打开')
  }
}
